# Maintainer:
pkgname=qbs
pkgver=2.4.2
pkgrel=0
pkgdesc="Cross platform Qt build tool"
url="https://wiki.qt.io/Qbs"
arch="all"
license="LGPL-3.0-or-later AND GPL-2.0-or-later"
makedepends="clang cmake qt6-qtbase-dev qt6-qt5compat-dev samurai"
source="https://download.qt.io/official_releases/qbs/$pkgver/qbs-src-$pkgver.tar.gz"
builddir="$srcdir/qbs-src-$pkgver"
options="!check" # todo

build() {
	case "$CARCH" in
	arm*|aarch64|riscv64|loongarch64)
		# not supported by clang here
		export CFLAGS="${CFLAGS/-fstack-clash-protection}"
		export CXXFLAGS="${CXXFLAGS/-fstack-clash-protection}"
		;;
	esac

	CC=clang CXX=clang++ \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWITH_TESTS="$(want_check && echo ON || echo OFF)" \
		-DQBS_LIBEXEC_INSTALL_DIR=lib/qbs
	cmake --build build
}

check() {
	ctest -j6 --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	rm -rf "$pkgdir"/usr/share/qbs/examples/
}

sha512sums="
e584b03e7866991bb5fdfd1caed33beaa9480b820772bdbd0daf049f7d3fbe7d1ab19add520c69fd018e9298ff13ca8dfaae3b76e6245589708b59f976307464  qbs-src-2.4.2.tar.gz
"
